/**
 * 主页js
 */
if (window.location.href == 'http://jyj.jl.gov.cn/' || window.location.href == 'http://jyj.jl.gov.cn/index.html') {
	_EsdDynamicTransformationScript.getIframeInfos = function(jsObj, iframeObj) {
		jsObj.aLink_num = iframeObj.contentWindow.document.getElementsByTagName("a").length;
		jsObj.first_aLink = iframeObj.contentWindow.document.getElementsByTagName("a")[0];
		jsObj.last_aLink = iframeObj.contentWindow.document.getElementsByTagName("a")[jsObj.aLink_num - 1];
		jsObj.self = iframeObj;
	};

	//将iframe所包含的a链接数 第一个a元素 最后一个a元素赋值给第一个参数的js对象
	_EsdDynamicTransformationScript.getIframeInfos = function(jsObj,iframeObj){
		if(iframeObj != undefined){
			jsObj.aLink_num = iframeObj.contentWindow.document.getElementsByTagName("a").length;
			jsObj.first_aLink = iframeObj.contentWindow.document.getElementsByTagName("a")[0];
			jsObj.last_aLink = iframeObj.contentWindow.document.getElementsByTagName("a")[jsObj.aLink_num-1];
			jsObj.self = iframeObj;
		}
	};

	//声明iframe操作对象
	_EsdDynamicTransformationScript.iframe1 = {};
	_EsdDynamicTransformationScript.iframe2 = {};

	_EsdDynamicTransformationScript.iframeElement1 = document.getElementsByTagName("iframe")[0];   // 需要修改 这里的iframe获取
	_EsdDynamicTransformationScript.iframeElement2 = document.getElementsByTagName("iframe")[1];   // 需要修改 这里的iframe获取

	// 选项卡标签 jquery对象
	_EsdDynamicTransformationScript.iframeTab1 = $(".zyxx .zyxx_title a:eq(0)"); // 需要修改
	// 这里的tab获取
	_EsdDynamicTransformationScript.iframeTab2 = $(".zyxx .zyxx_title a:eq(1)"); // 需要修改

	// 判断iframe是否有效
	if((_EsdDynamicTransformationScript.iframeElement1!=undefined) && (_EsdDynamicTransformationScript.iframeElement2!=undefined)){

		// 当iframe都加载完毕后执行代码 使用setInterval
		_EsdDynamicTransformationScript.iframeInterval = setInterval(function(){	
			
			if((_EsdDynamicTransformationScript.iframeElement1.contentWindow.document.getElementsByTagName("a")[0]!=undefined) 
					&&_EsdDynamicTransformationScript.iframeElement2.contentWindow.document.getElementsByTagName("a")[0]!=undefined ){
				clearInterval(_EsdDynamicTransformationScript.iframeInterval);
				
				//通过方法赋值   
				_EsdDynamicTransformationScript.getIframeInfos(_EsdDynamicTransformationScript.iframe1,_EsdDynamicTransformationScript.iframeElement1);  
				_EsdDynamicTransformationScript.getIframeInfos(_EsdDynamicTransformationScript.iframe2,_EsdDynamicTransformationScript.iframeElement2); 

				// 第一个标签 切换
				_EsdDynamicTransformationScript.iframeTab1.focus(function(e) {
					viewz(1);
//					e = $(this).mouseover();
					$(document).bind("keydown.iframeKeydown_1", function(e) {
						if (e.shiftKey && e.keyCode == 9) {
							_EsdDynamicTransformationScript.iframeTab1.trigger("blur");
							$(".main .gzdt a:last").focus();
							return false;
						} else if (e.keyCode == 9) {
							_EsdDynamicTransformationScript.iframeTab1.trigger("blur");
							$(_EsdDynamicTransformationScript.iframe1.self).focus();
							return false;
						}
					});
				});
				_EsdDynamicTransformationScript.iframeTab1.blur(function() {
					$(document).unbind("keydown.iframeKeydown_1");
				});
			
				// 第一个标签的第一个链接
				$(_EsdDynamicTransformationScript.iframe1.first_aLink).focus(function() {
					$(_EsdDynamicTransformationScript.iframe1.self.contentWindow.document).bind("keydown.iframeKeydown_first1", function(e) {
						if (e.shiftKey && e.keyCode == 9) {
							$(document).trigger("blur");
							_EsdDynamicTransformationScript.iframeTab1.focus();
							return false;
						} else if (e.keyCode == 9) {
						}
					});
				});
				$(_EsdDynamicTransformationScript.iframe1.first_aLink).blur(function() {
					$(_EsdDynamicTransformationScript.iframe1.self.contentWindow.document).unbind("keydown.iframeKeydown_first1");
				});
			
				// 第一个标签的最后一个链接
				$(_EsdDynamicTransformationScript.iframe1.last_aLink).focus(function() {
					$(_EsdDynamicTransformationScript.iframe1.self.contentWindow.document).bind("keydown.iframeKeydown_first1", function(e) {
						if (e.shiftKey && e.keyCode == 9) {
							
						} else if (e.keyCode == 9) {
							viewz(2);
							$(document).trigger("blur");
							_EsdDynamicTransformationScript.iframeTab2.focus();
							return false;
						}
					});
				});
				$(_EsdDynamicTransformationScript.iframe1.last_aLink).blur(function() {
					$(_EsdDynamicTransformationScript.iframe1.self.contentWindow.document).unbind("keydown.iframeKeydown_first1");
				});
			
				// 第二个标签切换
				_EsdDynamicTransformationScript.iframeTab2.focus(function(e) {
//					e = $(this).mouseover();
					$(document).bind("keydown.iframeKeydown_2", function(e) {
						if (e.shiftKey && e.keyCode == 9) {
							viewz(1);
							_EsdDynamicTransformationScript.iframeTab2.trigger("blur");
							_EsdDynamicTransformationScript.iframeTab1.mouseover();
							$(_EsdDynamicTransformationScript.iframe1.last_aLink).focus();
							return false;
						} else if (e.keyCode == 9) {
							_EsdDynamicTransformationScript.iframeTab2.trigger("blur");
							$(_EsdDynamicTransformationScript.iframe2.self).focus();
							return false;
						}
					});
			
				});
				_EsdDynamicTransformationScript.iframeTab2.blur(function() {
					$(document).unbind("keydown.iframeKeydown_2");
				});
			}
			
		}, 500);

	}
}